using System.Collections.Generic;
using UnityEngine;

public class PauseUI_level : MonoBehaviour
{
	private GameObject pauseobj;

	public UIEventListener continuebtn;

	public UIEventListener mainbtn;

	public UIEventListener settingbtn;

	public List<UILabel> taskstarlabel;

	private bool starflag;

	public UILabel titlename;

	private void Start()
	{
		continuebtn.onClick = ClickContinueBtn;
		mainbtn.onClick = ClickMainBtn;
		settingbtn.onClick = setBtn;
	}

	public void init_ui_info()
	{
		int curlevelnum = TasksController.instance.curlevelnum;
		titlename.text = "关卡 " + (curlevelnum / 6 + 1) + "-" + (curlevelnum % 6 + 1);
		starinfo();
	}

	public void starinfo()
	{
		if (starflag)
		{
			return;
		}
		LevelStar levelStar = new LevelStar();
		for (int i = 0; i < 3; i++)
		{
			levelStar = TasksController.instance.StarList[i];
			taskstarlabel[i].text = i + 1 + ". ";
			switch (levelStar.type)
			{
				case 1:
					taskstarlabel[i].text += "完成关卡";
					break;
				case 2:
					{
						UILabel uILabel2 = taskstarlabel[i];
						string text = uILabel2.text;
						uILabel2.text = text + "至少 " + levelStar.sontype + "% 血量";
						break;
					}
				case 3:
					switch (levelStar.sontype)
					{
						case 0:
							taskstarlabel[i].text += "击败所有敌人";
							break;
						case 1:
							taskstarlabel[i].text += "击落所有战斗机";
							break;
						case 2:
							taskstarlabel[i].text += "摧毁所有建筑";
							break;
						case 3:
							taskstarlabel[i].text += "击沉所有战舰";
							break;
					}
					break;
				case 4:
					switch (levelStar.sontype)
					{
						case 0:
							taskstarlabel[i].text += "保护所有友方单位";
							break;
						case 1:
							taskstarlabel[i].text += "保护所有友方战斗机";
							break;
						case 2:
							taskstarlabel[i].text += "保护所有友方建筑";
							break;
						case 3:
							taskstarlabel[i].text += "保护所有友方战舰";
							break;
					}
					break;
				case 5:
					{
						UILabel uILabel = taskstarlabel[i];
						string text = uILabel.text;
						uILabel.text = text + "在 " + levelStar.sontype / 60 + " 分钟内完成关卡";
						break;
					}
				case 6:
					taskstarlabel[i].text += "潜在任务成功";
					break;
				case 7:
					taskstarlabel[i].text += "成功完成速度竞赛";
					break;
			}
		}
		starflag = true;
	}

	public void enable()
	{
		if (pauseobj == null)
		{
			pauseobj = base.gameObject;
		}
		init_ui_info();
		NGUITools.SetActive(pauseobj, state: true);
	}

	public void ClickContinueBtn(GameObject btn)
	{
		MonoInstance<AudioController>.instance.play(AudioType.UI_BTN, 0f);
		GameUIController.instance.disable_pauseui_level();
	}

	public void ClickMainBtn(GameObject btn)
	{
		Platform.HideFeatureView();
		MenuUIController.beginshow = BeginShow.main;
		Time.timeScale = 1f;
		UnityEngine.SceneManagement.SceneManager.LoadScene("Menu");
		MidLoading.loadlevel = 0;
	}

	public void setBtn(GameObject btn)
	{
		MonoInstance<AudioController>.instance.play(AudioType.UI_BTN, 0f);
		disable();
		GameUIController.instance.enable_optionui();
	}

	public void disable()
	{
		NGUITools.SetActive(pauseobj, state: false);
	}
}
